package com.yjy.mybase.utils;

import android.widget.Toast;

import com.yjy.mybase.BaseApplication;

/**
 * by:yangjnyang
 * 提示框 工具类
 */
public class ToastUtils {

    private static Toast toastObj;
    private static boolean isEnable;

    public static void toast(String toast) {

        if (toastObj != null) {
            toastObj.cancel();
        }
        toastObj = Toast.makeText(BaseApplication.getContext(), toast, Toast.LENGTH_SHORT);
        if (isEnable) {
            toastObj.show();
        }
    }

    public static void cancleToast() {
        if (toastObj != null) toastObj.cancel();
        isEnable = false;
    }

    public static void enableToast() {
        isEnable = true;
    }


    /**
     * 无状态 提示 不会根据提示消息
     *
     * @param toast
     */
    public static void toastNoStates(String toast) {
        Toast.makeText(BaseApplication.getContext(), toast, Toast.LENGTH_SHORT).show();
    }

    private static Toast mToast;

    public static void show(String toast) {
        if (mToast != null) {
            mToast.cancel();
        }
        mToast = Toast.makeText(BaseApplication.getContext(), toast, Toast.LENGTH_SHORT);
        mToast.show();
    }
}
